#!/usr/bin/env php
<?php
namespace TwinPeaks\UnitTesting;
use \TwinPeaks\Core as Core;

require 'core/CShell.php';

class CShell extends Core\CShell {
	const OPT_RUN_ALL = 1;
	
	function getUserAppNamespace() {
		return __NAMESPACE__;
	}
	
	function getAppDirectory() {
		return realpath(__DIR__ . '/../protected');
	}
	
	function getFrameworkDirectory() {
		return realpath(__DIR__ . '/..');
	}
	
	/**
	 * 
	 * @return
	 */
	function runAllTests() {
		$test = new CCore;
		try {
			$r = $test->run();
		}
		catch(\Exception $e) {
			var_dump($e);
		}
		//var_dump(get_class_methods($r));
	}
	
	/**
	 * @return void
	 */
	protected function defineOptions() {
		$this->addOption(self::OPT_RUN_ALL, 'a', 'all', true);
	}
	
	/**
	 * @return void
	 */
	protected function registerFrameworkNS() {
		parent::registerFrameworkNS();
		$this->registerNamespace('\\' . __NAMESPACE__, realpath(__DIR__ . '/tests'));
	}
	
	/**
	 * @return void
	 */
	protected function init() {
		//$t = new \\CDb::getInstance();
		//$t = new Core\Http\CUri;
		//var_dump($t);
		$this->autoloadAddPrefixEx('PHP(Unit|_Timer)');
		
		//$this->registerNamespace(__NAMESPACE__, $paths)
		if ($this->optionHasTrueValue(self::OPT_RUN_ALL)) {
			$this->runAllTests();
			//var_Dump($this->getOptionValue(self::OPT_RUN_ALL));
		}
	}
}

CShell::run();